From 63c75a23847f5e46c599ae5417f6b755a886ce48 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 26 Oct 2012 17:57:03 +0200 Subject: [PATCH] texthandles: Add an extra style class to the cursor-mode handle Themes may want to render handles differently depending on whether the widget is in selection mode (2 handles enclosing a selection) or cursor mode (one handle pointing out the insertion cursor). --- docs/reference/gtk/gtk3-sections.txt | 1 + gtk/gtkstylecontext.h | 9 +++++++++ gtk/gtktexthandle.c | 10 ++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index be5315f78d..9e159b160c 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -5779,6 +5779,7 @@ GTK_STYLE_CLASS_ARROW GTK_STYLE_CLASS_OSD GTK_STYLE_CLASS_LEVEL_BAR GTK_STYLE_CLASS_CURSOR_HANDLE +GTK_STYLE_CLASS_INSERTION_CURSOR GTK_STYLE_REGION_COLUMN GTK_STYLE_REGION_COLUMN_HEADER GTK_STYLE_REGION_ROW diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index 1783d4c6a1..8731cba327 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -709,6 +709,15 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_CURSOR_HANDLE "cursor-handle" +/** + * GTK_STYLE_CLASS_INSERTION_CURSOR: + * + * A CSS class used when rendering a drag handle for + * the insertion cursor position. + */ +#define GTK_STYLE_CLASS_INSERTION_CURSOR "insertion-cursor" + + /* Predefined set of widget regions */ /** diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index 3d06ee4e09..6c7033b28a 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -108,8 +108,14 @@ _gtk_text_handle_draw (GtkTextHandle *handle, GTK_STYLE_CLASS_CURSOR_HANDLE); if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END) - gtk_style_context_add_class (priv->style_context, - GTK_STYLE_CLASS_BOTTOM); + { + gtk_style_context_add_class (priv->style_context, + GTK_STYLE_CLASS_BOTTOM); + + if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR) + gtk_style_context_add_class (priv->style_context, + GTK_STYLE_CLASS_INSERTION_CURSOR); + } else gtk_style_context_add_class (priv->style_context, GTK_STYLE_CLASS_TOP); -- 2.30.2